package com.konglz.consumer.listener;

import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Description
 * @Author konglz
 * @Data 2023/5/13 11:43
 */
@Component
public class WorkMessageListener {

    @RabbitListener(queuesToDeclare = @Queue("workQueue"))
    public void listenerWorkQueueConsumer1(String message) throws InterruptedException {
        System.out.println(1 + "=====消费者1接收到的消息：" + message + LocalDateTime.now());
        Thread.sleep(20);
    }

    @RabbitListener(queuesToDeclare = @Queue("workQueue"))
    public void listenerWorkQueueConsumer2(String message) throws InterruptedException {
        System.err.println(1 + "=====费者2接收到的消息：" + message + LocalDateTime.now());
        Thread.sleep(20);
    }

}
